﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////

#pragma once
#include "GmepCommonData.h"
#include "IGmepCategoryInfo.h"

namespace gmep
{
    // Disciplines,categories and classes read from MDMCategory.qpd
    // 
   
    class GMEP_COMMONDATA_EXPORT GmepCategoryInfo : public IGmepCategoryInfo
    {
        CANNOT_COPY_OR_ASSIGN(GmepCategoryInfo);
    public:
        GmepCategoryInfo();
        virtual ~GmepCategoryInfo(){};

        GmepCategoryInfo(const std::wstring sId ,const std::wstring code, const std::wstring name,
            const std::wstring desc, const std::wstring parentId,
            std::map<std::wstring, gcmp::OwnerPtr<gmep::IGmepCategoryInfo>> categoryCodeList);

        static gcmp::OwnerPtr<GmepCategoryInfo> Create();

        // 加入时的顺序
        virtual int GetOrder() const override { return m_order; }
        virtual void SetOrder(const int order) override { m_order = order; }

        // guid string
        virtual std::wstring GetId() const override { return m_id; }
        virtual void SetId(const std::wstring& sid) override { m_id = sid; }
        // 数据库映射id
        virtual std::wstring GetMappedId() const override { return m_mappedId; }
        virtual void SetMappedId(const std::wstring& sid) override { m_mappedId = sid; }
        // 标准码
        virtual std::wstring GetStandardCode() const override { return m_standardCode; }
        virtual void SetStandardCode(const std::wstring& sCode) override { m_standardCode = sCode; }

        // guid string of parent  // todo 
        virtual std::wstring GetParentId() const override { return m_parentId; }
        virtual void SetParentId(const std::wstring& sid) override { m_parentId = sid; }

        //  
        virtual std::wstring GetCode() const override { return m_code; }
        virtual void SetCode(const std::wstring& code) override { m_code = code; }

        // local name
        virtual const std::wstring GetName() const override { return m_localName; }
        virtual void SetName(const std::wstring& name) override { m_localName = name; }
        // local description
        virtual const std::wstring GetDesc() const override { return m_localDesc; }
        virtual void SetDesc(const std::wstring& desc) override { m_localDesc = desc; }

        virtual void AddCategoryInfo(gcmp::OwnerPtr<gmep::IGmepCategoryInfo> category) override;
        virtual std::map<std::wstring, const gmep::IGmepCategoryInfo *>  GetCategoryInfoList() const override;
        // 获取子分类的ownerptr, 慎用
        virtual std::map<std::wstring, gcmp::OwnerPtr<gmep::IGmepCategoryInfo >> GetCategoryInfoOwnerPtrList() override;

        virtual void AddPropertyInfo(gcmp::OwnerPtr<gmep::IGmepPropertyInfo> prop) override;
        virtual std::map<std::wstring, const gmep::IGmepPropertyInfo *>  GetPropertyInfoList() const override;
        virtual const gmep::IGmepPropertyInfo * GetPropertyInforByStandardCode(const std::wstring stdCode) const override;

        virtual bool GetTechnicalCurve() const override { return m_hasTechnicalCurve; }
        virtual void SetTechnicalCurve(bool hasTechnicalCurve) override { m_hasTechnicalCurve = hasTechnicalCurve; }

        virtual bool GetComputeSpecification() const override { return m_hasComputeSpecification; }
        virtual void SetComputeSpecification(bool hasComputeSpecification) override { m_hasComputeSpecification = hasComputeSpecification; }

    private:
        std::wstring m_id; // guid string with -
        std::wstring m_parentId; // guid string with -  // 可以为空
        std::wstring m_code;
        std::wstring m_localName; // 根据当前语言读取不同字段
        std::wstring m_localDesc; // 根据当前语言读取不同字段
        bool m_hasTechnicalCurve;
        bool m_hasComputeSpecification;
        std::map<std::wstring, gcmp::OwnerPtr<gmep::IGmepCategoryInfo>> m_categoryList;    // 可以为空
        //std::map<std::wstring, GmepClassification> m_classList; // 可以为空

        std::map<std::wstring, gcmp::OwnerPtr<gmep::IGmepPropertyInfo>> m_propertyList; // 可以为空 // guid to property
        

        std::wstring m_mappedId; //可以为空; // mapped db id, from anther mapped table
        std::wstring m_standardCode;

        int m_order;
    };

    class GMEP_COMMONDATA_EXPORT GmepDisciplineInfo:public IGmepDisciplineInfo
    {
        CANNOT_COPY_OR_ASSIGN(GmepDisciplineInfo);
    public:
        GmepDisciplineInfo();
        virtual ~GmepDisciplineInfo() {};
        GmepDisciplineInfo(const std::wstring &code, const std::wstring &name, std::map<std::wstring,
            gcmp::OwnerPtr<gmep::IGmepCategoryInfo>> categoryCodeList);

        static gcmp::OwnerPtr<GmepDisciplineInfo> Create();
        // 顺序
        virtual int GetOrder() const override { return m_order; }
        virtual void SetOrder(const int order) override { m_order = order; }

        // guid string
        virtual std::wstring GetId() const override { return m_id; }
        virtual void SetId(const std::wstring& sid) override { m_id = sid; }
        // code
        virtual std::wstring GetCode() const override { return m_code; }
        virtual void SetCode(const std::wstring& code) override { m_code = code; }

        // 标准码
        virtual std::wstring GetStandardCode() const override { return m_standardCode; }
        virtual void SetStandardCode(const std::wstring& sCode) override { m_standardCode = sCode; }

        // local name
        virtual const std::wstring GetName() const override { return m_localName; }
        virtual void SetName(const std::wstring& name) override { m_localName = name; }
        // local devirtual scription
        virtual const std::wstring GetDesc() const override { return m_localDesc; }
        virtual void SetDesc(const std::wstring& desc) override { m_localDesc = desc; }

        virtual void AddCategoryInfo(gcmp::OwnerPtr<gmep::IGmepCategoryInfo> cate) override;
        virtual std::map<std::wstring, const gmep::IGmepCategoryInfo*>  GetCategoryInfoList() const override;

        virtual std::map<std::wstring, gcmp::OwnerPtr<gmep::IGmepCategoryInfo >> GetCategoryInfoOwnerPtrList() override;
    private:
        std::wstring m_id;
        std::wstring m_code;
        std::wstring m_localName;  
        std::wstring m_localDesc;

        std::wstring m_standardCode;
        
        std::map<std::wstring, gcmp::OwnerPtr<gmep::IGmepCategoryInfo>> m_categoryList;

        int m_order;
    };
}